<style>
	.mid-bottom thead tr th{
		text-align: center;
	}
	.mid-bottom tbody tr td{
		text-align: center;
	}
</style>
		<!--conter-->		
		<div class="conter">
			<h2><a href="index.html">首页</a><a href="user.html">>会员中心</a>>地址管理</h2>
			<div class="conter-left">
				<ul>
					<li>
						<h1>订单中心</h1>
						<a href="order.html">我的订单</a>
						<a href="#">我的回购订单</a>
						<a href="#">我的意外保单</a>
					</li>
					<li>
						<h1>个人中心</h1>
						<a href="{:U('User/address')}" class="on">地址管理</a>
						<a href="#">我的收藏</a>
						<a href="#">消息提醒</a>
						<a href="#">建议反馈</a>
					</li>
					<li>
						<h1>个人中心</h1>
						<a href="#">我的优惠券</a>
						<a href="#">我的红包</a>
						<a href="#">我的回购券</a>
					</li>
					<li>
						<h1>服务中心</h1>
						<a href="#">退款跟踪</a>
						<a href="#">补办意外保</a>
						<a href="#">以旧换新</a>
					</li>
				</ul>
			</div>
			<div class="conter-right">
				<div class="mid-top">
					<h3>新增收货地址<i>（您目前有地址1个，还可以再增加9个）</i></h3>
					<label class="name">
						<a><i>收货人姓名</i><input type="text" id="shname" placeholder="长度不超过12个字" name="name"></a>
						<a><i>收货人手机号</i><input type="text" name="phone" id="phone" placeholder="输入11位手机号"></a>	
					</label>
					<label class="site">
						<i>收货人地址</i>

						<td>
								<select id="s_province" name="s_province"></select>  
							    <select id="s_city" name="s_city" ></select>
							    <select id="s_county" name="s_county"></select>
							    <input type="text" id="village" placeholder="乡镇/街道"/>
						</td>
						<div id="show"></div>
						
						
						
					</label>
					<label class="detail-site">
						<i>详细地址</i>
						<input type="text" id="site" placeholder="请输入不超过50个字的详细地址" />
					</label>
					<div class="default">
						<label>
							<input type="checkbox"/>
							<span>设为默认</span>
						</label>	
					</div>
					<button id="hold">保存</button>
				</div>
				
				<div class="mid-bottom">
					<h3>已有地址</h3>
					<table>
						<thead>
							<tr>
								<th>收货人姓名</th>
								<th>收货人手机号</th>
								<th>收货人地址</th>
								<th>操作</th>
							</tr>
						</thead>
						<tbody>
							<volist name='addre' id='addr'>
								<tr>
									<td class="td-name">{$addr.shname}</td>
									<td class="td-phone">{$addr.phone}</td>
									<td class="td-hold">{$addr.province}{$addr.city}{$addr.county}{$addr.village}{$addr.detail.site}</td>
									<td class="td-handle">
										<input type="hidden" name="address_id" value="{$addr.address_id}">
										<span class="delete">删除</span>
										<span class="alter" onclick="edit('地址修改','{:U(\'User/address_edit\',array(\'address_id\'=>$addr[\'address_id\']))}',945,395)">修改</span>
										<label><i class="mo">设为</i>默认</label>
									</td>
								</tr>
							</volist>
						</tbody>
					</table>
				</div>
				<!--mid-bottom-->
			</div>
		</div>
				


<script type="text/javascript">_init_area()</script>
<script type="text/javascript">
    var Gid  = document.getElementById ;
    var showArea = function() {
        Gid('show').innerHTML = "<h3>省" + Gid('s_province').value + " - 市" +    
        Gid('s_city').value + " - 县/区" + 
        Gid('s_county').value + "</h3>"
    }
    Gid('s_county').setAttribute('onchange','showArea()');
</script>


<script type="text/javascript">
	$("#hold").click(function(){

		var shname = $("#shname").val();
		var phone = $("#phone").val();
		var province = $("#s_province").val();
		var city = $("#s_city").val();
		var county = $("#s_county").val();
		var village = $("#village").val();
		var site = $("#site").val();
		var check = $(".mid-top .default label").find("input").is(':checked');
		var defau = 0;//是否默认
		if(check){
			defau = 1;
		}
		$.post("",{shname:shname,phone:phone,province:province,city:city,county:county,village:village,detail_site:site,defau:defau,status:1},function(data){
			if(data.code == 0){
				layer.alert(data.info);
			}else{
				layer.alert(data.info,{end:function(){
					window.location.reload();
				}});
				
			}
		})
		return false;
	})


	$(".mid-top .default label").click(function(){
		if($(this).find("input").is(":checked")){
			$(this).addClass("on");
		}else{
			$(this).removeClass("on");
		}
	})

	$(".delete").click(function(){
		var add_id = $(this).prev().val();
		layer.confirm('确定要删除吗',function(){
			$.post("",{add_id:add_id,status:2},function(data){
				if(data.code == 1){
					layer.alert(data.info,{end:function(){
						window.location.reload();
					}});
				}else{
					layer.alert(data.info);
				}
			})
		});
	})

	function edit(title,url,w,h){
		layer_show(title,url,w,h);
	}

	$(".td-handle label").click(function(){
		var address_id = $(this).siblings().eq(0).val();

		$.post("",{address_id:address_id,status:3},function(data){
			if(data.code == 1){
				layer.alert(data.info);
			}else{
				layer.alert(data.info);
			}
		})
	})
	

</script>